<?php
namespace core\lib

class conf{
	static public $conf = array();
	static public function get($name,$file)
	{
		/*1 判读配置文件是否存在
		2 判断对应的配置是否存在
		3 缓存配置*/
		if(isset(self::$conf[$file]))
		{
			return self::$conf[$file][$name];
		}
		else
		{
			$file = CONF_DIR.'/'.$file.'php';
			if(is_file($file))
			{
				$conf = include $file;
				if(isset($conf[$name]))
				{
					self::$conf[$file] = $conf;
					return $conf[$name];
				}
				else
				{
					throw new \Exception("没有这个控制项".$name);
					
				}
			}
			else
			{
				throw new \Exception("找不到配置文件", $file);
				
			}
		}
		
	}
	//加载所有配置项
	stutic public function all($file)
	{
		if(isset(self::$conf[$file]))
		{
			return self::$conf[$file][$name];
		}
		else
		{
			$file = CONF_DIR.'/'.$file.'php';
			if(is_file($file))
			{
				$conf = include $file;
				self::$conf[$file] = $conf;
				return $conf;
			}
			else
			{
				throw new \Exception("找不到配置文件", $file);
				
			}
		}
	}
}